{extend name="wap/default_new/base" /}

{block name="goodsHead"}

<section class="head">
		<a class="head_back"  href='javascript:history.back(-1)'><i class="icon-back"></i></a>
		<div class="head-title">{$search_title}</div>
	</section>
<style>
	.head-title {
    margin: 0 80px;
    height: 44px;
    line-height: 44px;
    color: #333;
    font-size: 16px;
    text-align: center;
    width: 80%;
    margin: auto;
    margin-left: 15%;
}
.custom-search{
	padding: 0px;
	background-color:#f7f7f7;
}
.custom-search form {
    margin: 0;
    position: relative;
    background: none;
    border-radius: 4px;
    border: 0 none;
    overflow: hidden;
}
.custom-search-button {
    top: 6px;
}
.members_goodspic{
	margin-top: 45px;
}
.info p.goods-title a{
	height:20px;
	overflow:hidden;
}
</style>
{/block}
{block name="main"}
	<link rel="stylesheet" type="text/css" href="__TEMP__/{$style}/public/css/goods_list.css">
<section class="members_goodspic" id="main_list">    
 	<ul class="tablelist-append">
 	</ul>
</section>
<!-- 总页数 -->
<input type="hidden" id="page_count">
<!-- 当前页数 -->
<input type="hidden" id="page" value="1">
<script>

$(function(){
    getgoodlist(1);
});
var is_load = true;//防止重复加载
function getgoodlist(page){
    $('#grouGoodsListmask').hide();
    $('.two-list-menu').hide();
    $('.two-list-menu li[pid]').hide();
    var order = $("#order").val();
    var sort = $("#sort").val();
    var min_price = $("#min_price").val();
    var max_price = $("#max_price").val();
    var attr = $("#attr").val();
    var spec = $("#spec").val();
    var brand_id = $("#brand_id").val();
    //展示方式
    $("#page").val(page);
    if(is_load){
        is_load = false;
        $.ajax({
            type:"post",
            url : "{:__URL('APP_MAIN/Shop/goodsList')}",
            data : {
                'type':'{$type}',
				'shop_id':'{$shop_id}'
            },
            success : function(data){
                data = data.data;
                $("#page_count").val(data['page_count']);//总页数
                if(page == 1){
                    var list_html = "";
                }else if(page > 1){
                    var list_html = $('.tablelist-append').html();
                }

                if(data['data'].length >0){

                    for(var i=0;i<data['data'].length;i++){
                        var item=data['data'][i];
                        list_html += '<li class="gooditem">';
                        list_html += '<div class="imgs">';
                        list_html += '<a href="'+ __URL('APP_MAIN/goods/goodsdetail?id='+item.goods_id)+'">';
                        list_html += '<img src="{:__IMG($default_goods_img)}" class="lazy lazy_load" data-original="'+__IMG(item.pic_cover_small)+'" >';
                        list_html += '</a>';
                        list_html += '</div>';
                        list_html += '<div class="info">';
                        list_html += '<p class="goods-title"><a href="'+__URL('APP_MAIN/goods/goodsdetail?id='+item.goods_id) + '">'+item.goods_name+'</a></p>';
                        list_html += '<p class="goods-price"><em>￥'+item.promotion_price+'</em></p>';
                        list_html += '<a href="'+ __URL('APP_MAIN/goods/goodsdetail?id='+item.goods_id)+'">';
                        list_html += '<div class="goods-buy"></div>';
                        list_html += '</a>';
                        list_html += '</div>';
                        list_html += '</li>';
					}
                }else if(data["data"].length == 0 && page == 1){
                    list_html+= '<p style="color:#939393;text-align:center;margin-top:100px;"><img src="__TEMP__/{$style}/public/images/wap_nodata.png" height="60" style="margin-bottom:20px;"><br>Sorry！{:lang("goods_no_goods_you_want")}…</p>';
                }
                is_load = true;
                $('.tablelist-append').html(list_html);
//                console.log(list_html);
                img_lazyload();
                var	goods_img_height = parseInt($('.goods_img').height());
                $(".data_info").height(goods_img_height);
            }
        });
    }
}

$('.order_div span').click(function(){
    $('.order_div span').removeClass('select');
    $(this).addClass('select');
    GetgoodsList($(this).attr('value'));
})
$('.order_div span:nth-child(3)').click(function(){
    if(!$(this).children().is('.statu_two')){
        $(this).children().addClass('statu_two');
    }else{
        $(this).children().removeClass('statu_two');
    }
})


//滑动到底部加载
$(window).scroll(function(){
    var totalheight = parseFloat($(window).height()) + parseFloat($(window).scrollTop());
    var content_box_height = parseFloat($(".members_goodspic").height());
//    console.log(totalheight - content_box_height);return;
    if(totalheight - content_box_height >= 40){
        if(is_load){
            var page = parseInt($("#page").val()) + 1;//页数
            var total_page_count = $("#page_count").val(); // 总页数
            if(page > total_page_count){
                return false;
            }else{
                getgoodlist(page);
            }
        }

    }
})
</script>		
{/block}

{block name="bottom"}
{/block}